package com.itxiuyixiu.volunteer.controller;

import com.itxiuyixiu.entity.enums.AuthorityType;
import com.itxiuyixiu.entity.model.Activity;
import com.itxiuyixiu.tools.util.returns.ReturnVo;
import com.itxiuyixiu.volunteer.service.TeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;

/**
 * @author 黄磊
 * @date 2020/5/4
 */
@Api(tags = "老师API")
@Validated
@RequestMapping("/teacher")
@RestController
public class TeacherController {
    @Autowired
    private TeacherService teacherService;

    @ApiOperation(value = "查看所有要审核的活动" , response = Activity.class)
    @GetMapping("/checking/activities")
    public ReturnVo findAllCheckingActivity() {
        return ReturnVo.getSuccessReturn(teacherService.findAllCheckingActivity());
    }

    @ApiOperation(value = "审核活动" , response = String.class)
    @PutMapping("/checking/activity/{activityId}")
    public ReturnVo checkActivity(@PathVariable("activityId") Integer activityId ,@NotNull(message = "审核结果不能为空") Boolean checkResult) {
        switch (teacherService.checkActivity(activityId , checkResult)) {
            case 0: return ReturnVo.getSuccessReturn("成功修改活动状态为审核成功");
            case 1: return ReturnVo.getFailureReturn("要修改状态的活动不存在");
            case 2: return ReturnVo.getSuccessReturn("成功修改活动状态为审核失败");
            case 3: return ReturnVo.getSuccessReturn("无法修改已经通过的活动");
            default: return ReturnVo.getFailureReturn("服务器发生未知错误");
        }
    }
}
